package com.utf999.qiangmanger.filter;

import java.io.File;
import java.io.FilenameFilter;
import java.util.regex.Pattern;

public class SQLFileFilter implements FilenameFilter {

	private String pattern;
	
	public SQLFileFilter(){
		this.pattern = "^*[a-zA-z0-9]*.sql.xml$";
	}
	
	public SQLFileFilter(String pattern){
		this.pattern = "^" + pattern.replaceAll("\\*", "[a-zA-z0-9]*") + "$";
	}
	
	public boolean accept(File dir, String name) {
		Pattern pattern = Pattern.compile(this.pattern);
		return pattern.matcher(name).matches();
	}

}
